/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.ex;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Calendar;
import java.util.Random;

/**
 * <p>Project: jse2204 - Ex10
 * <p>Powered by webrx On 2022-09-01 09:11:04
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex10 {
    public static void main(String[] args) throws ParseException {
        //指定日期范围的随机日期 2022-1-1 0:0:0 - now
        //var start = LocalDateTime.of(2022, 1, 1, 0, 0, 0).toInstant(ZoneOffset.of("+8")).toEpochMilli();

        //var c = Calendar.getInstance();
        //c.set(2022,1-1,1,0,0,0);
        //var start = c.getTimeInMillis();

        var sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        var start = sdf.parse("2000-1-1 0:0:0").getTime();

        var end = System.currentTimeMillis();
        //var time = start +  Math.round(Math.random() * (end - start));

        Random rand = new Random();
        for (int i = 0; i < 10; i++) {
            //var time = start +  Math.round(Math.random() * (end - start));

            //java 1.8
            var time = rand.nextLong(start,end);
            //System.out.println(time);
            System.out.printf("%tF %<tT%n", time);
        }


        //2022-1-1 0:0:0 - now 的随机日期
        //var a = LocalDateTime.of(2022, 1, 1, 0, 0, 0).toInstant(ZoneOffset.of("+8")).toEpochMilli();
        //var ca = Calendar.getInstance();
        //ca.set(2022,1-1,1,0,0,0);
        //var a2 = ca.getTimeInMillis();
        //var sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //var a3 = sdf.parse("2022-01-01 00:00:00").getTime();
        //System.out.println(a);
        //System.out.println(a2);
        //System.out.println(a3);
        //
        ////结束日期
        //var b = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
        //var c = System.currentTimeMillis();
        //var d = new Date().getTime();
        //var e = Calendar.getInstance().getTimeInMillis();


    }
}
